import Foundation

protocol DWJsonStringValue {}

extension String : DWJsonStringValue {}

extension NSString : DWJsonStringValue {}

func dw_string(_ value : Any, type : Any.Type) -> DWJsonStringValue? {
    var str: String
    switch value {
    case let url as URL: str = url.standardizedFileURL.absoluteString
    case let date as Date: str = "\(Int64(date.timeIntervalSince1970))"
    default: str = "\(value)"
    }
    return type is NSMutableString.Type ? NSMutableString(string: str) : str
}
